export default function saveBrowseHistory(historyData, SellBrowseHistory='') {
  if(SellBrowseHistory==='SellBrowseHistory') {
    if(localStorage.SellBrowseHistory) {
      let SellBrowseHistory = JSON.parse(localStorage.SellBrowseHistory)
      SellBrowseHistory = SellBrowseHistory.filter(data=> JSON.stringify(historyData)!=JSON.stringify(data))
      if (SellBrowseHistory.length>=5) {
        SellBrowseHistory.pop()
      }
      SellBrowseHistory.unshift(historyData)
      localStorage.setItem('SellBrowseHistory', JSON.stringify(SellBrowseHistory))
    } else {
      localStorage.setItem('SellBrowseHistory', JSON.stringify([historyData]))
    }
  } else {
    if(localStorage.BrowseHistory) {
      let BrowseHistory = JSON.parse(localStorage.BrowseHistory)
      BrowseHistory = BrowseHistory.filter(data=>JSON.stringify(data) !== JSON.stringify(historyData))
      if (BrowseHistory.length>=5) {
        BrowseHistory.pop()
      }
      BrowseHistory.unshift(historyData)
      localStorage.setItem('BrowseHistory', JSON.stringify(BrowseHistory))
    } else {
      localStorage.setItem('BrowseHistory', JSON.stringify([historyData]))
    }
  }

}
